using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace Inventory.Domain.Models.Mapping
{
    public class PersonMap : EntityTypeConfiguration<Person>
    {
        public PersonMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            // Table & Column Mappings
            this.ToTable("People");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.FirstName).HasColumnName("FirstName");
            this.Property(t => t.MiddleName).HasColumnName("MiddleName");
            this.Property(t => t.LastName).HasColumnName("LastName");
            this.Property(t => t.DateOfBirth).HasColumnName("DateOfBirth");
            this.Property(t => t.GenderId).HasColumnName("GenderId");

            // Relationships
            this.HasRequired(t => t.Gender)
                .WithMany(t => t.People)
                .HasForeignKey(d => d.GenderId);

        }
    }
}
